package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ZhwyChargeitemRentalcontract;
import com.ruoyi.service.IZhwyChargeitemRentalcontractService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合同与收费项关联中间Controller
 * 
 * @author ruoyi
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/feeSettings/cRental")
public class ZhwyChargeitemRentalcontractController extends BaseController
{
    @Autowired
    private IZhwyChargeitemRentalcontractService zhwyChargeitemRentalcontractService;

    /**
     * 查询合同与收费项关联中间列表
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:cRental:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhwyChargeitemRentalcontract zhwyChargeitemRentalcontract)
    {
        startPage();
        List<ZhwyChargeitemRentalcontract> list = zhwyChargeitemRentalcontractService.selectZhwyChargeitemRentalcontractList(zhwyChargeitemRentalcontract);
        return getDataTable(list);
    }

    /**
     * 导出合同与收费项关联中间列表
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:cRental:export')")
    @Log(title = "合同与收费项关联中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhwyChargeitemRentalcontract zhwyChargeitemRentalcontract)
    {
        List<ZhwyChargeitemRentalcontract> list = zhwyChargeitemRentalcontractService.selectZhwyChargeitemRentalcontractList(zhwyChargeitemRentalcontract);
        ExcelUtil<ZhwyChargeitemRentalcontract> util = new ExcelUtil<ZhwyChargeitemRentalcontract>(ZhwyChargeitemRentalcontract.class);
        util.exportExcel(response, list, "合同与收费项关联中间数据");
    }

    /**
     * 获取合同与收费项关联中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:cRental:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zhwyChargeitemRentalcontractService.selectZhwyChargeitemRentalcontractById(id));
    }

    /**
     * 新增合同与收费项关联中间
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:cRental:add')")
    @Log(title = "合同与收费项关联中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhwyChargeitemRentalcontract zhwyChargeitemRentalcontract)
    {
        System.out.println("两个id"+zhwyChargeitemRentalcontract.toString());
        return toAjax(zhwyChargeitemRentalcontractService.insertZhwyChargeitemRentalcontract(zhwyChargeitemRentalcontract));
    }

    /**
     * 修改合同与收费项关联中间
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:cRental:edit')")
    @Log(title = "合同与收费项关联中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhwyChargeitemRentalcontract zhwyChargeitemRentalcontract)
    {
        return toAjax(zhwyChargeitemRentalcontractService.updateZhwyChargeitemRentalcontract(zhwyChargeitemRentalcontract));
    }

    /**
     * 删除合同与收费项关联中间
     */
    @PreAuthorize("@ss.hasPermi('feeSettings:cRental:remove')")
    @Log(title = "合同与收费项关联中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zhwyChargeitemRentalcontractService.deleteZhwyChargeitemRentalcontractByIds(ids));
    }

    @GetMapping("/rid/{id}")
    public List selectByRid(@PathVariable Long id){
        List list = zhwyChargeitemRentalcontractService.selectByRid(id);
        return list;
    }
}
